package com.atguigu.gulimall.search.ThreadTest;

import java.util.concurrent.TimeUnit;

public class DeadLock {

    public static void main(String[] args) {

        Object o1 = new Object();
        Object o2 = new Object();


        new Thread(()->{
            synchronized (o1){
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                synchronized (o2){

                }
            }
        }).start();

        new Thread(()->{
            synchronized (o2){
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                synchronized (o1){

                }
            }
        }).start();
    }
}
